package org.example.service;

import org.example.entity.Admin;
import org.example.repository.AdminRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class AdminService {

    private final AdminRepository adminRepository;

    @Autowired
    public AdminService(AdminRepository adminRepository) {
        this.adminRepository = adminRepository;
    }

    public Admin login(String username, String password) {
        Admin admin = adminRepository.findByUsername(username);
        if (admin != null && admin.getPassword().equals(password) && admin.isEnabled()) {
            return admin;
        }
        return null;
    }

    public void logout() {
        // 实现logout逻辑，例如清除认证信息或会话
        // 这里可以添加具体的注销逻辑
    }
}
